const CracoLessPlugin = require("craco-less");
const path = require("path");
const resolve = (dir) => path.resolve(__dirname, dir);
module.exports = {
  plugins: [{ plugin: CracoLessPlugin }], //配置less
  webpack: {
    alias: {
      // 配置路径别名
      "@": resolve("src"),
      "@components": resolve("src/components"),
      "@utils": resolve("src/utils"),
    },
  },
  // babel: {
  //   // antd包在craco增量配置中的按需加载配置: 我们在页面中用到什么组件，babel-plugin-import 这个包就会帮助我们自动导入组件的样式。
  //   plugins: [
  //     ["import", { libraryName: "antd", libraryDirectory: "es", style: "css" }],
  //   ],
  // },
  // 配置跨域
  devServer: {
    port: 3000,
    open: false,
    proxy: {
      "/lqb": {
        target: "https://m.lanqb.com",
        changeOrigin: true,
        pathRewrite: {
          "^/lqb": "",
        },
      },
      "/bd": {
        target: "https://www.baidu.com",
        changeOrigin: true,
        pathRewrite: {
          "^/bd": "",
        },
      },
    },
  },
};
